package com.api.util;

import java.util.Map;

public class MobilePhoneGenerator {


    /**
     * 返回一个可以注册的手机号
     * toBeRegisterMobilePhone
     * toBeRegisterMobilephone
     * @return phone
     */
    public String toBeRegisterMobilePhone(){
        String sql="select concat(max(username)+1,'') as mobilePhone from tb_member";
        //String sql ="select max(username) as mobilePhone from tb_member";
        try{
            Map<String,Object> map=JDBCUtil.query(sql,null);
            String phone=map.get("mobilePhone").toString();
            System.out.println(phone);
            return phone;
        }catch (Exception e){
            e.printStackTrace();
        }
        return "";
    }

    /**
     * 返回一个还没有注册过的手机号
     * @return
     */
    public String notRegisterYetMobilePhone(){
        String sql="select concat(max(username)+2,'') as mobilePhone from tb_member";
        Map<String,Object> map=JDBCUtil.query(sql,null);
        String phone=map.get("mobilePhone").toString();
        System.out.println(phone);
        return phone;
    }

    public static void main(String[] args){
        MobilePhoneGenerator m = new MobilePhoneGenerator();
        m.toBeRegisterMobilePhone();
        m.notRegisterYetMobilePhone();
    }
}
